package com.mxpio.erp.common.purchase.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.jpa.model.Notice;
import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PURC_NOTICE")
@Schema(description="收货通知单")
public class ReceivingNotice extends Notice {

	private static final long serialVersionUID = 1L;

	@Override
    public String initTypeCode() {
        return "RO1";
    }

    @Schema(description = "采购订单号")
    @Column(name = "PURCHASE_ORDER_BIZ_NO_")
    private String purchaseOrderBizNo;

    @Transient
    private PurchaseOrder purchaseOrder;
    @Transient
    private List<ReceivingNoticeLine> receivingOrderLines;
	@Override
	public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
        NoticeLine noticeLine = new ReceivingNoticeLine();
        noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
        noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
        noticeLine.setItemCode(orderExcuteVo.getItemCode());
        noticeLine.setNoticeNo(this.getNoticeNo());
        noticeLine.setQuantity(orderExcuteVo.getQuantity());
        noticeLine.setSort(orderExcuteVo.getSort());
        noticeLine.setLotNo(orderExcuteVo.getLotNo());
        noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
        return noticeLine;
	}

	@Override
	public List<? extends NoticeLine> getNoticeLines() {
		return receivingOrderLines;
	}
}
